package com.doyled.jump.animation;

import java.awt.Graphics;

import com.doyled.jump.IGame.GameInterface;

public class DiceAnimation extends Animation {
	private int value;		//value of dice
	private int newValue;	//expecting value

	public int getValue() {
		return value;
	}

	public DiceAnimation() {
		super();
		this.animatingFlag = false;
		this.value = 1;			//set starting dice is one
	}

	public void setAnimation(int time, int newValue) {
		this.second = time;
		this.totalFrames = 60 * this.second;
		this.frame = 0;
		this.newValue = newValue;
		this.animatingFlag = true;
	}

	/**
	 * animating in a specific set time
	 * animatingFlag is true for animating
	 * and animatingFlag is false for not animating
	 */
	@Override
	public void tick() {
		if (frame < totalFrames) {
			if (frame % 6 == 0) {
				this.value = (this.value + 1) % 6 + 1;
			}
			frame++;
		} else if (frame == totalFrames) {
			this.value = this.newValue;
			frame++;
		} else {
			this.animatingFlag = false;
		}
	}
}
